<?php
    header('content-type:text/html charset:utf-8');   
	error_reporting(0);
    $dir_base ="houseimg/".date(Ym).'/';
    if(!file_exists($dir_base)){
	    mkdir($dir_base);
    }
    $index = 0;    
    foreach($_FILES as $file){
        $upload_file_name = 'upload_file' . $index;
        $filename = $_FILES[$upload_file_name]['name'];
        $file_ext=strtolower(trim(array_pop(explode('.',$filename))));
		for($i=0;$i<10;$i++){
			$saveName.=substr('abcdefhjkmnpqrstuvwxy345678ABCDEFGHJKLMNPQRSTUVWXY0oz2il1g9',(mt_rand(0,58)),1);
		}
		$filename=$saveName.date('YmdHis').'.'.$file_ext;
        if(!file_exists($dir_base.$filename)) {
            $isMoved = false;
            $rEFileTypes = "/^\.(mp4|wmv|rmvb){1}$/i"; 
            if (preg_match($rEFileTypes, strrchr($filename, '.'))) {
                $isMoved =move_uploaded_file ( $_FILES[$upload_file_name]['tmp_name'], $dir_base.$filename);
            }
        }else{
            $isMoved = true;
        }
        if($isMoved){
            $output = $dir_base.$filename;
        }else {
            $output= "";
        }
        $index++;
    }
    echo $output;
    